package com.ids.actions;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
import com.ids.bean.TeamAttendanceData;
import com.ids.bean.UserInfo;
import com.ids.service.TeamAttendanceService;
import com.ids.util.Constants;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class TeamAttendanceScreen extends ActionSupport {

	private static final long serialVersionUID = 1L;
	private List<TeamAttendanceData> teamAttendanceData;
	private List<TeamAttendanceData> dependantAttendanceTypeData;
	private int attendanceTypeId;
	private int dependantAttendanceTypeId;
	private final int APPROVED = 2;

	public String execute() throws Exception {
		Map<String, Object> session = ActionContext.getContext().getSession();
		HttpServletRequest request = ServletActionContext.getRequest();
		UserInfo userInfo = (UserInfo) session.get("userInfo");
		List<TeamAttendanceData> teamAttendanceData = TeamAttendanceService
		.getInstance().getTeamAttendanceData(userInfo);
		setTeamAttendanceData(teamAttendanceData);
		String dataManipulationData = (String) session
		.get(Constants.DATA_MANIPULATION_MESSAGE);
		request.setAttribute(Constants.DATA_MANIPULATION_MESSAGE,
		dataManipulationData);
		session.remove(Constants.DATA_MANIPULATION_MESSAGE);
		return SUCCESS;
	}

	public int getAttendanceTypeId() { 
		return attendanceTypeId;
	}

	public void setAttendanceTypeId(int attendanceTypeId) {
		this.attendanceTypeId = attendanceTypeId;
	}

	public List<TeamAttendanceData> getTeamAttendanceData() {
		return teamAttendanceData;
	}

	public void setTeamAttendanceData(
			List<TeamAttendanceData> teamAttendanceData) {
		this.teamAttendanceData = teamAttendanceData;
	}

	public int getStatusTypeId() {
		return APPROVED;
	}

	public List<Integer> getApproval() {
		return Arrays.asList(1, 3, 4, 5, 6, 7, 8, 9);
	}

	public float[] getCompOffs() {
		float arr[] = { 0, .5f, 1 };
		return arr;
	}

	public int getDependantAttendanceTypeId() {
		return dependantAttendanceTypeId;
	}

	public void setDependantAttendanceTypeId(int dependantAttendanceTypeId) {
		this.dependantAttendanceTypeId = dependantAttendanceTypeId;
	}

	public List<TeamAttendanceData> getDependantAttendanceTypeData() {
		return dependantAttendanceTypeData;
	}

	public void setDependantAttendanceTypeData(
			List<TeamAttendanceData> dependantAttendanceTypeData) {
		this.dependantAttendanceTypeData = dependantAttendanceTypeData;
	}
}
